import Mock from 'mockjs2'
import { builder } from '../util'

const totalCount = 5701

const priceList = () => {
  const result = []
  const pageNo = 0
  const pageSize = 4
  const totalPage = Math.ceil(totalCount / pageSize)
  const key = (pageNo - 1) * pageSize
  const next = (pageNo >= totalPage ? (totalCount % pageSize) : pageSize) + 1
  for (let i = 1; i < next; i++) {
    const tmpKey = key + i
    result.push({
      key: tmpKey,
      id: tmpKey,
      business_name: '商标注册' + tmpKey,
      business_group: '',
      price1: '4500.00',
      price2: '8500.00',
      price3: '12500.00',
      created_at: Mock.mock('@datetime'),
      update_at: Mock.mock('@datetime')
    })
  }

  return builder({
    pageSize: pageSize,
    pageNo: pageNo,
    totalCount: totalCount,
    totalPage: totalPage,
    data: result
  })
}

Mock.mock(/\/price/, 'get', priceList)
